package com.cn.qtms.controller;//类注释设置模板

import com.cn.qtms.base.controller.BaseController;
import com.cn.qtms.base.service.BaseService;
import com.cn.qtms.common.page.PageRes;
import com.cn.qtms.common.result.QueryParam;
import com.cn.qtms.common.result.Result;
import com.cn.qtms.common.result.ResultUtil;
import com.cn.qtms.entity.TmSecGoods;
import com.cn.qtms.service.TmSecGoodsService;
import com.cn.qtms.vo.SecGoodsVo;
import com.cn.qtms.vo.SecWeeksVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.print.attribute.standard.Severity;

/**
 * @Name:TmSecGoodsController
 * @Description:
 * @Author: zhangyang
 * @Date: 2019-12-25 19:26
 **/
@RestController
@RequestMapping("sec-goods")
public class TmSecGoodsController extends BaseController<TmSecGoods,Long> {
    @Autowired
    private TmSecGoodsService service;
    @Override
    protected BaseService<TmSecGoods, Long> getService() {
        return service;
    }

    @PostMapping("calWeeks")
    public Result<Integer> calWeeks(@RequestBody SecWeeksVo vo){
        return ResultUtil.success(service.calWeeks(vo));
    }


    /**
     * 获取秒杀场次对应的商品列表信息
     * @param request
     * @return
     */
        @PostMapping("findSecGoods")
    public Result<PageRes<SecGoodsVo>>  findSecGoods(@RequestBody QueryParam request){
        return ResultUtil.success(service.findSecGoods(request));
    }

    /**
     * 初始化秒杀商品列表信息 将数据库的秒杀商品提取到redis缓存中
     * @return
     */
    @GetMapping("initSecGoods")
    public Result initSecGoods(){
        service.initSecGoods();
        return ResultUtil.success();
    }
}
